package com.enjoyor.soa.traffic.rest.efoms.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.enjoyor.soa.traffic.api.dto.efoms.DeviceWranInfoDto;
import com.enjoyor.soa.traffic.api.dto.efoms.WranTacticsInfoDto;
import com.enjoyor.soa.traffic.frame.annotation.Auth;
import com.enjoyor.soa.traffic.frame.security.bean.dto.UserDto;
import com.enjoyor.soa.traffic.rest.efoms.dubbo.IFacilitySimpleInfoConsumeService;
import com.enjoyor.soa.traffic.rest.efoms.dubbo.IDeviceWranInfoConsumeService;
import com.enjoyor.soa.traffic.rest.efoms.dubbo.IWranTacticsConsumeService;
import com.enjoyor.soa.traffic.rest.efoms.enums.EnumDicPublicRest;
import com.enjoyor.soa.traffic.util.enums.EnumAppCode;
import com.enjoyor.soa.traffic.util.helper.ResultHelper;
import com.enjoyor.soa.traffic.util.pojo.Page;
import com.enjoyor.soa.traffic.util.pojo.ResultPojo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@Auth
@RestController
@RequestMapping({ "/deviceDetail/" })
@Api("报警策略rest接口")
@CrossOrigin
public class FacilitySimpleInfoController {
	@Autowired
	private IFacilitySimpleInfoConsumeService facilitySimpleConsumeService;

	@GetMapping(value = { "selectFacilitySimpleInfoById" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiOperation("根据编号查询设施信息")
	@ApiImplicitParams({ 
		@ApiImplicitParam(name = "facilityTypeCode", value = "设施类型编号", paramType = "query", required = true, dataType = "String"),
		@ApiImplicitParam(name = "facilityId", value = "设施编号", paramType = "query", required = true, dataType = "String")})
	public ResultPojo selectFacilitySimpleInfoById(
			@RequestParam(defaultValue = "", value = "facilityTypeCode", required = true) String facilityTypeCode,
			@RequestParam(defaultValue = "", value = "facilityId", required = true) String facilityId,
			HttpServletRequest request) {
		ResultPojo resultPojo = new ResultPojo();
		if(!(EnumDicPublicRest.TRAFFIC_MARKING.getKey().equals(facilityTypeCode) 
				||EnumDicPublicRest.TRAFFIC_RAILING.getKey().equals(facilityTypeCode)
				||EnumDicPublicRest.TRAFFIC_SIGN.getKey().equals(facilityTypeCode))) {
			resultPojo = ResultHelper.getResult(EnumAppCode.PARAM_ERR, "设施类型编号参数错误！");
		}
		resultPojo = facilitySimpleConsumeService.selectFacilitySimpleInfoById(facilityTypeCode, facilityId);
		return resultPojo;
	}
	
	@GetMapping(value = { "selectFacilitySimpleInfoList" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiOperation("查询设施列表信息")
	@ApiImplicitParams({ 
		@ApiImplicitParam(name = "facilityTypeCode", value = "设施类型编号", paramType = "query", required = true, dataType = "String"),
		@ApiImplicitParam(name = "facilityId", value = "设施编号", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "facilityName", value = "设施名称", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "key", value = "关键字（设施编号或设施名称）", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "devStatusCode", value = "设施状态编号", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "regionId", value = "管辖区域编号", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "signsType", value = "设施子类编号", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "signsCode", value = "设施小类编号", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "roadId", value = "道路编号", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "blockId", value = "路段编号", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "crossId", value = "路口编号", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "manageDept", value = "管理部门编号", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "manufact", value = "生产厂家", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "repStatusCode", value = "报修状态编号", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "buildBeginDate", value = "建设开始日期", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "buildEndDate", value = "建设结束日期", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "updateBeginTime", value = "更新开始日期", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "updateEndTime", value = "更新结束日期", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "deviceStatus", value = "使用状态编号", paramType = "query", dataType = "String")})
	public ResultPojo selectFacilitySimpleInfoList(
			@RequestParam(defaultValue = "", value = "facilityTypeCode", required = true) String facilityTypeCode,
			@RequestParam(defaultValue = "", value = "facilityId", required = false) String facilityId,
			@RequestParam(defaultValue = "", value = "facilityName", required = false) String facilityName,
			@RequestParam(defaultValue = "", value = "key", required = false) String key,
			@RequestParam(defaultValue = "", value = "devStatusCode", required = false) String devStatusCode,
			@RequestParam(defaultValue = "", value = "regionId", required = false) String regionId,
			@RequestParam(defaultValue = "", value = "signsType", required = false) String signsType,
			@RequestParam(defaultValue = "", value = "signsCode", required = false) String signsCode,
			@RequestParam(defaultValue = "", value = "roadId", required = false) String roadId,
			@RequestParam(defaultValue = "", value = "blockId", required = false) String blockId,
			@RequestParam(defaultValue = "", value = "crossId", required = false) String crossId,
			@RequestParam(defaultValue = "", value = "manageDept", required = false) String manageDept,
			@RequestParam(defaultValue = "", value = "manufact", required = false) String manufact,
			@RequestParam(defaultValue = "", value = "repStatusCode", required = false) String repStatusCode,
			@RequestParam(defaultValue = "", value = "buildBeginDate", required = false) String buildBeginDate,
			@RequestParam(defaultValue = "", value = "buildEndDate", required = false) String buildEndDate,
			@RequestParam(defaultValue = "", value = "updateBeginTime", required = false) String updateBeginTime,
			@RequestParam(defaultValue = "", value = "updateEndTime", required = false) String updateEndTime,
			@RequestParam(defaultValue = "", value = "deviceStatus", required = false) String deviceStatus,
			HttpServletRequest request) {
		ResultPojo resultPojo = new ResultPojo();
		if(!(EnumDicPublicRest.TRAFFIC_MARKING.getKey().equals(facilityTypeCode) 
				||EnumDicPublicRest.TRAFFIC_RAILING.getKey().equals(facilityTypeCode)
				||EnumDicPublicRest.TRAFFIC_SIGN.getKey().equals(facilityTypeCode))) {
			resultPojo = ResultHelper.getResult(EnumAppCode.PARAM_ERR, "设施类型编号参数错误！");
		}
		resultPojo = facilitySimpleConsumeService.selectFacilitySimpleInfoList(facilityTypeCode, facilityId, facilityName,
				key, devStatusCode, regionId, signsType, signsCode, roadId, blockId, crossId, manageDept, manufact,
				repStatusCode, buildBeginDate, buildEndDate, updateBeginTime, updateEndTime,deviceStatus);
		return resultPojo;
	}
	
	@GetMapping(value = { "selectFacilitySimpleInfoPage" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiOperation("查询设备详细分页信息")
	@ApiImplicitParams({ 
		@ApiImplicitParam(name = "facilityTypeCode", value = "设施类型编号", paramType = "query", required = true, dataType = "String"),
		@ApiImplicitParam(name = "facilityId", value = "设施编号", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "facilityName", value = "设施名称", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "key", value = "关键字（设施编号或设施名称）", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "devStatusCode", value = "设施状态编号", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "regionId", value = "管辖区域编号", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "signsType", value = "设施子类编号", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "signsCode", value = "设施小类编号", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "roadId", value = "道路编号", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "blockId", value = "路段编号", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "crossId", value = "路口编号", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "manageDept", value = "管理部门编号", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "manufact", value = "生产厂家", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "repStatusCode", value = "报修状态编号", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "buildBeginDate", value = "建设开始日期", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "buildEndDate", value = "建设结束日期", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "updateBeginTime", value = "更新开始日期", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "updateEndTime", value = "更新结束日期", paramType = "query", dataType = "String"),
		@ApiImplicitParam(name = "deviceStatus", value = "使用状态编号", paramType = "query", dataType = "String")})
	public ResultPojo selectFacilitySimpleInfoPage(
			@RequestParam(defaultValue = "", value = "facilityTypeCode", required = true) String facilityTypeCode,
			@RequestParam(defaultValue = "", value = "facilityId", required = false) String facilityId,
			@RequestParam(defaultValue = "", value = "facilityName", required = false) String facilityName,
			@RequestParam(defaultValue = "", value = "key", required = false) String key,
			@RequestParam(defaultValue = "", value = "devStatusCode", required = false) String devStatusCode,
			@RequestParam(defaultValue = "", value = "regionId", required = false) String regionId,
			@RequestParam(defaultValue = "", value = "signsType", required = false) String signsType,
			@RequestParam(defaultValue = "", value = "signsCode", required = false) String signsCode,
			@RequestParam(defaultValue = "", value = "roadId", required = false) String roadId,
			@RequestParam(defaultValue = "", value = "blockId", required = false) String blockId,
			@RequestParam(defaultValue = "", value = "crossId", required = false) String crossId,
			@RequestParam(defaultValue = "", value = "manageDept", required = false) String manageDept,
			@RequestParam(defaultValue = "", value = "manufact", required = false) String manufact,
			@RequestParam(defaultValue = "", value = "repStatusCode", required = false) String repStatusCode,
			@RequestParam(defaultValue = "", value = "buildBeginDate", required = false) String buildBeginDate,
			@RequestParam(defaultValue = "", value = "buildEndDate", required = false) String buildEndDate,
			@RequestParam(defaultValue = "", value = "updateBeginTime", required = false) String updateBeginTime,
			@RequestParam(defaultValue = "", value = "updateEndTime", required = false) String updateEndTime,
			@RequestParam(defaultValue = "", value = "deviceStatus", required = false) String deviceStatus,
			Page page, HttpServletRequest request) {
		ResultPojo resultPojo = new ResultPojo();
		if(!(EnumDicPublicRest.TRAFFIC_MARKING.getKey().equals(facilityTypeCode) 
				||EnumDicPublicRest.TRAFFIC_RAILING.getKey().equals(facilityTypeCode)
				||EnumDicPublicRest.TRAFFIC_SIGN.getKey().equals(facilityTypeCode))) {
			resultPojo = ResultHelper.getResult(EnumAppCode.PARAM_ERR, "设施类型编号参数错误！");
		}
		resultPojo = facilitySimpleConsumeService.selectFacilitySimpleInfoPage(facilityTypeCode, facilityId, facilityName,
				key, devStatusCode, regionId, signsType, signsCode, roadId, blockId, crossId, manageDept, manufact,
				repStatusCode, buildBeginDate, buildEndDate, updateBeginTime, updateEndTime,deviceStatus, page);
		return resultPojo;
	}
}
